/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Ui;

import java.awt.List;
import java.util.ArrayList;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Esteban
 */
public class PanelAsignarClase extends javax.swing.JPanel {

    /**
     * Creates new form PanelAsignarClase
     */
    public PanelAsignarClase() {
        initComponents();
        initComponents2();
//        ((GrupoCompartidoTableModel)tablaClase.getModel()).anadirGrupo(new PanelGrupoCompartido());
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        clase = new javax.swing.JLabel();
        scrollEstudiante = new javax.swing.JScrollPane();
        tablaEstudiante = new javax.swing.JTable();
        btnBusquedaEstudiante = new javax.swing.JButton();
        campoBusquedaEstudiante = new javax.swing.JTextField();
        btnCancelarEstudiante = new javax.swing.JButton();
        scrollClase = new javax.swing.JScrollPane();
        tablaClase = new javax.swing.JTable();

        clase.setFont(new java.awt.Font("Calibri", 1, 20)); // NOI18N
        clase.setText("Asignar Estudiante a Clase Compartida");

        scrollEstudiante.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true), "Seleccione el estudiante:", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Calibri", 1, 18), new java.awt.Color(0, 102, 255))); // NOI18N

        tablaEstudiante.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        tablaEstudiante.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Cédula", "Nombre"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaEstudiante.setGridColor(new java.awt.Color(0, 102, 204));
        scrollEstudiante.setViewportView(tablaEstudiante);

        btnBusquedaEstudiante.setText("Búsqueda:");
        btnBusquedaEstudiante.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                btnBusquedaEstudianteMousePressed(evt);
            }
        });

        campoBusquedaEstudiante.setEnabled(false);
        campoBusquedaEstudiante.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                campoBusquedaEstudianteKeyReleased(evt);
            }
        });

        btnCancelarEstudiante.setText("Cancelar");
        btnCancelarEstudiante.setEnabled(false);
        btnCancelarEstudiante.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                btnCancelarEstudianteMousePressed(evt);
            }
        });

        scrollClase.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true), "Seleccione el grupo a asignarle al estudiante", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Calibri", 1, 18), new java.awt.Color(0, 102, 255))); // NOI18N

        tablaClase.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        tablaClase.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Clases Compartidas"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaClase.setGridColor(new java.awt.Color(0, 102, 204));
        scrollClase.setViewportView(tablaClase);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(203, 203, 203)
                .addComponent(clase, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(213, 213, 213))
            .addGroup(layout.createSequentialGroup()
                .addGap(135, 135, 135)
                .addComponent(btnBusquedaEstudiante)
                .addGap(63, 63, 63)
                .addComponent(campoBusquedaEstudiante, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(67, 67, 67)
                .addComponent(btnCancelarEstudiante)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(scrollEstudiante, javax.swing.GroupLayout.PREFERRED_SIZE, 530, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(105, 105, 105))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(scrollClase, javax.swing.GroupLayout.PREFERRED_SIZE, 630, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(52, 52, 52))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addComponent(clase)
                .addGap(32, 32, 32)
                .addComponent(scrollEstudiante, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoBusquedaEstudiante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnBusquedaEstudiante)
                    .addComponent(btnCancelarEstudiante))
                .addGap(35, 35, 35)
                .addComponent(scrollClase, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(42, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnBusquedaEstudianteMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnBusquedaEstudianteMousePressed
        // TODO add your handling code here:
        //activarBusquedaEst();
    }//GEN-LAST:event_btnBusquedaEstudianteMousePressed

    private void campoBusquedaEstudianteKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoBusquedaEstudianteKeyReleased
        // TODO add your handling code here:
        //busquedaEst();
    }//GEN-LAST:event_campoBusquedaEstudianteKeyReleased

    private void btnCancelarEstudianteMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCancelarEstudianteMousePressed
        // TODO add your handling code here:
        //desactivarBusquedaEst();
    }//GEN-LAST:event_btnCancelarEstudianteMousePressed

    private void initComponents2(){
        ArrayList<PanelGrupoCompartido> lista = new ArrayList<PanelGrupoCompartido>();
        tablaClase.setModel(new GrupoCompartidoTableModel(lista));
        CeldaGrupoCompartido celda = new CeldaGrupoCompartido();
        tablaClase.setDefaultRenderer(PanelGrupoCompartido.class, celda);
        tablaClase.setDefaultEditor(PanelGrupoCompartido.class, celda);
        tablaClase.setRowHeight(113);
    }
    
    public class GrupoCompartidoTableModel extends AbstractTableModel {
        ArrayList grupos;
 
        public GrupoCompartidoTableModel(ArrayList grupos) {
            this.grupos = grupos;
        }
        
        public void anadirGrupo(PanelGrupoCompartido panel){
            grupos.add(panel);
        } 
 
        public Class getColumnClass(int columnIndex) { return PanelGrupoCompartido.class; }
        public int getColumnCount() { return 1; }
        public String getColumnName(int columnIndex) { return "Clases compartidas"; }
        public int getRowCount() { return grupos.size(); }
        public Object getValueAt(int rowIndex, int columnIndex) { return (grupos == null) ? null : grupos.get(rowIndex); }
        public boolean isCellEditable(int columnIndex, int rowIndex) { return true; }
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBusquedaEstudiante;
    private javax.swing.JButton btnCancelarEstudiante;
    private javax.swing.JTextField campoBusquedaEstudiante;
    private javax.swing.JLabel clase;
    private javax.swing.JScrollPane scrollClase;
    private javax.swing.JScrollPane scrollEstudiante;
    private javax.swing.JTable tablaClase;
    private javax.swing.JTable tablaEstudiante;
    // End of variables declaration//GEN-END:variables
}
